home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / manageme / snmp-dev.000 / snmp-dev / snmp_impl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-09  |  4.1 KB  |  155 lines

  1. /*
  2.  * Definitions for SNMP (RFC 1067) implementation.
  3.  *
  4.  *
  5.  */
  6. /***********************************************************
  7.     Copyright 1988, 1989 by Carnegie Mellon University
  8.  
  9.                       All Rights Reserved
  10.  
  11. Permission to use, copy, modify, and distribute this software and its 
  12. documentation for any purpose and without fee is hereby granted, 
  13. provided that the above copyright notice appear in all copies and that
  14. both that copyright notice and this permission notice appear in 
  15. supporting documentation, and that the name of CMU not be
  16. used in advertising or publicity pertaining to distribution of the
  17. software without specific, written prior permission.  
  18.  
  19. CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  20. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  21. CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  22. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  23. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  24. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  25. SOFTWARE.
  26. ******************************************************************/
  27.  
  28.  
  29. #if (defined vax) || (defined (mips))
  30. /*
  31.  * This is a fairly bogus thing to do, but there seems to be no better way for
  32.  * compilers that don't understand void pointers.
  33.  */
  34. #define void char
  35. #endif
  36.  
  37. /*
  38.  * Error codes:
  39.  */
  40. /*
  41.  * These must not clash with SNMP error codes (all positive).
  42.  */
  43. #define PARSE_ERROR    -1
  44. #define BUILD_ERROR    -2
  45.  
  46. #define COMMUNITY_MAX_LEN    64
  47. #define MAX_NAME_LEN        128  /* number of subid's in a objid */
  48.  
  49. #ifndef NULL
  50. #define NULL 0
  51. #endif
  52.  
  53. #ifndef TRUE
  54. #define TRUE    1
  55. #endif
  56. #ifndef FALSE
  57. #define FALSE    0
  58. #endif
  59.  
  60. struct packet_info {
  61.     int     version;
  62.     u_char     pdutype;
  63.  
  64.     /* community based authentication */
  65.     u_char    community[COMMUNITY_MAX_LEN + 1];
  66.     int        community_len;
  67.     int        community_id;
  68.  
  69.     /* snmp security based authentication */
  70.     oid            srcParty[64];
  71.     oid        dstParty[64];
  72.     oid        context[64];
  73.     int        srcPartyLength;
  74.     int        dstPartyLength;
  75.     int        contextLength;
  76.     struct partyEntry *srcp, *dstp;
  77.     struct contextEntry *cxp;
  78.  
  79.     u_char    *packet_end;
  80. };
  81.  
  82. #define READ        1
  83. #define WRITE        0
  84.  
  85. #define RESERVE1    0
  86. #define RESERVE2    1
  87. #define COMMIT      2
  88. #define ACTION        3
  89. #define FREE        4
  90.  
  91. /* See important comment in snmp_vars.c relating to a change
  92.    in the way the access control word is interpreted */
  93. #define RONLY    0xAAAA    /* read access for everyone */
  94. #define RWRITE    0xAABB    /* add write access for community private */
  95. #define NOACCESS 0x0000    /* no access for anybody */
  96.  
  97. #define INTEGER        ASN_INTEGER
  98. #define STRING        ASN_OCTET_STR
  99. #define OBJID        ASN_OBJECT_ID
  100. #define NULLOBJ        ASN_NULL
  101. #define BITSTRING   ASN_BIT_STR
  102.  
  103. /* defined types (from the SMI, RFC 1157) */
  104. #define IPADDRESS   (ASN_APPLICATION | 0)
  105. #define COUNTER        (ASN_APPLICATION | 1)
  106. #define GAUGE        (ASN_APPLICATION | 2)
  107. #define TIMETICKS   (ASN_APPLICATION | 3)
  108. #define OPAQUE        (ASN_APPLICATION | 4)
  109.  
  110. /* defined types (from the SMI, RFC ????) */
  111. #define NSAP        (ASN_APPLICATION | 5)
  112. #define COUNTER64   (ASN_APPLICATION | 6)
  113. #define UINTEGER    (ASN_APPLICATION | 7)
  114.  
  115. struct trapVar {
  116.     oid        *varName;
  117.     int        varNameLen;
  118.     u_char  varType;
  119.     int        varLen;
  120.     u_char  *varVal;
  121.     struct trapVar *next;  
  122. };
  123.  
  124. #ifdef DEBUG
  125. #define ERROR(string)    printf("%s(%d): %s\n",__FILE__, __LINE__, string);
  126. #else
  127. #define ERROR(string)
  128. #endif
  129.  
  130. /* from snmp.c*/
  131. extern u_char    sid[];    /* size SID_MAX_LEN */
  132.  
  133. u_char    *snmp_parse_var_op();
  134. u_char    *snmp_build_var_op();
  135.  
  136. /*
  137.  * For calling secauth_build, FIRST_PASS is an indication that a new nonce
  138.  * and lastTimeStamp should be recorded.  LAST_PASS is an indication that
  139.  * the packet should be checksummed and encrypted if applicable, in
  140.  * preparation for transmission.
  141.  * 0 means do neither, FIRST_PASS | LAST_PASS means do both.
  142.  * For secauth_parse, FIRST_PASS means decrypt the packet, otherwise leave it
  143.  * alone.  LAST_PASS is ignored.
  144.  */
  145. #define FIRST_PASS    1
  146. #define    LAST_PASS    2
  147. u_char    *snmp_auth_parse();
  148. u_char    *snmp_auth_build();
  149.  
  150. u_char    *snmp_secauth_parse();
  151. u_char    *snmp_secauth_build();
  152.  
  153.  
  154. int has_access();
  155.